<template>
	<div id="img-list-new">
		<div class="iln-container">
      <p>新建大屏分组</p>
      <input maxlength="20" v-model="groupname" placeholder="请输入分组名称">
      <div class="error">{{errormessage}}</div>
      <div class="iml-confirm">
        <span v-on:click="groupAdd">确定</span>
        <span v-on:click="cancel">取消</span>
      </div>
    </div>
	</div>
</template>
<script>
  import './list-new.less'
  import { mapActions } from 'vuex'
  export default {
    name: 'NewGroup',
    components: {
      
    },
    data () {
      return {
      	groupname:"",
        errormessage:""
      }
    },
    mounted:function(){
    },
    methods:{
      ...mapActions([
          'addGroup'
      ]),
      reVal(){
        this.groupname="";
        this.errormessage="";
      },
      groupAdd(){
        if (!this.groupname) {
            this.errormessage = "请输入分组名称";
            return;
        }
        var params = {
          title:this.groupname
        }
        this.addGroup({params}).then(function(res){
          if (res.code=="1") {
            this.errormessage="";
            this.$parent.getGroupList();
          }else{
            this.errormessage = res.message;
          }
        }.bind(this))
      },
      cancel(){
        this.$parent.hiddenNewGroup();
      }
    }
  }
</script>
